package com.slice.upload.task;

import com.slice.upload.entity.FileUploadRespond;
import com.slice.upload.strategy.FileUploadHandler;
import com.slice.upload.strategy.FileUploadPayload;

import java.util.concurrent.Callable;

/**
 * @ClassName FileUploadTask
 * @Description 异步上传文件任务
 * @Author frinder
 * @Date 2021/1/26 17:07
 * @Verion 1.0
 */
public class FileUploadTask implements Callable<FileUploadRespond> {

    private FileUploadHandler handler;
    private FileUploadPayload payload;

    public FileUploadTask(FileUploadHandler handler, FileUploadPayload payload) {
        this.handler = handler;
        this.payload = payload;
    }

    @Override
    public FileUploadRespond call() {
        // 调用策略处理器处理
        handler.handle(payload);
        // 返回处理结果
        return payload.getRespond();
    }
}
